package com.nycreativity.elecreativity.service.impl;

import com.baomidou.mybatisplus.extension.kotlin.KtQueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.nycreativity.elecreativity.entity.dto.UserRoleDTO
import com.nycreativity.elecreativity.entity.enums.IsDelEnum
import com.nycreativity.elecreativity.entity.po.*
import com.nycreativity.elecreativity.mapper.UserRoleMapper
import com.nycreativity.elecreativity.service.UserRoleService
import org.springframework.stereotype.Service
import javax.annotation.Resource

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ttxxi
 * @since 2021-11-04
 */
@Service
class UserRoleServiceImpl : ServiceImpl<UserRoleMapper, UserRole>(), UserRoleService {

    @Resource
    lateinit var userRoleMapper: UserRoleMapper

    override fun queryByUserId(userId: Long): List<UserRole> {
        val queryWrapper = KtQueryWrapper(UserRole::class.java)
            .eq(UserRole::userId, userId)
            .eq(Address::isDel, IsDelEnum.NO.code)
        return userRoleMapper.selectList(queryWrapper)
    }

    override fun queryUserRoleDTOByUserId(userId: Long?): List<UserRoleDTO> {
        return userRoleMapper.selectUserRoleDTOByUserId(userId)
    }



}
